package com.example.springboot.pattern.strategy;

public class LogisticsSystemWithStrategy {
    private DeliveryStrategy strategy;

    public void setDeliveryStrategy(DeliveryStrategy strategy) {
        this.strategy = strategy;
    }

    public double calculateDeliveryCost(double weight) {
        if (strategy == null) {
            throw new IllegalStateException("No delivery strategy set.");
        }
        return strategy.calculateCost(weight);
    }
}
